package cn.initcap.designpattern.pattern.behavioral.strategy;

/**
 * 策略模式
 *
 * @author initcap
 * @date Created in 2018/10/14 PM6:32.
 */
public class Test {

    public static void main(String[] args) {
        low();
        height();
        heighter();
    }

    /**
     * 最简单的版本策略模式
     */
    private static void low() {
        PromotionActivity promotionActivity618 = new PromotionActivity(new LiJianPromotionStrategy());
        PromotionActivity promotionActivity1111 = new PromotionActivity(new FanXianPromotionStrategy());

        promotionActivity618.executePromotionStrategy();
        promotionActivity1111.executePromotionStrategy();
    }

    /**
     * 策略➕工厂模式
     */
    private static void height() {
        String promotionKey = "FANXIAN";
        PromotionActivity promotionActivity = new PromotionActivity(promotionKey);
        promotionActivity.executePromotionStrategy();
    }

    /**
     * 策略+工厂+注解（实现自动注册）
     */
    private static void heighter() {
        PromotionActivity promotionActivity = new PromotionActivity(StrategyType.FANXIAN);
        promotionActivity.executePromotionStrategy();
    }
}
